package com.itheima.web.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 继承 重写 注解
 */
@WebServlet("/resp1")
public class ResponseDemo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("resp1....");
        // 重定向 resp2
        // 先设置状态码
        //resp.setStatus(302);
        // 设置定向的路径,从哪里开始
        //resp.setHeader("Location","/webdemo/resp2");
        // sendRedirect 这个方法内容相当于以上2步
        resp.sendRedirect("/webdemo/resp2");

    }
}
